/*!
\copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file       storage_manager_interface.h
\brief     The storage manager interface.
*/

#ifndef STORAGE_MANAGER_INTERFACE_H_
#define STORAGE_MANAGER_INTERFACE_H_

#include "storage_manager.h"

typedef struct storage_manager_interface_t
{
    void (*StorageManager_Initialize) (void);
    storage_mgr_buffer_handle_t (*StorageManager_OpenBuffer) (storage_mgr_addr_data_t, const storage_mgr_event_if *);
    bool (*StorageManager_LoadData) (storage_mgr_buffer_handle_t, uint32 offset, uint8 * buffer, size_t bytes);
    bool (*StorageManager_SaveData) (storage_mgr_buffer_handle_t, uint32 offset, const uint8 * buffer, size_t bytes);
    bool (*StorageManager_CloseBuffer) (storage_mgr_buffer_handle_t);
    bool (*StorageManager_ForceCloseAllBuffers) (void);
    size_t (*StorageManager_GetBufferSize) (storage_mgr_buffer_handle_t);
} storage_mgr_interface_t;

typedef struct singleton_instance_t
{
    storage_mgr_type_t type;
    const storage_mgr_interface_t * interface;
    bool is_initialized : 1;
} singleton_instance_t;

/*!
    Data shared between the storage manager library and its implementations. 
*/
typedef struct storage_manager_protected_data_t
{
    const storage_mgr_interface_t * interface; 
    const storage_mgr_event_if * events;
} storage_mgr_protected_data_t;

const storage_mgr_interface_t * StorageManager_GetSingletonInterfaceByType(storage_mgr_type_t type);

const singleton_instance_t * StorageManager_GetSingletonInstanceTable(void);

size_t StorageManager_GetSingletonInstanceTableSize(void);


#endif /* STORAGE_MANAGER_INTERFACE_H_ */